<?php

class wms_mdl_expressadjust extends dbeav_model
{

    var $objMath = null;
	public function searchOptions(){
        $parentOptions = parent::searchOptions();
        $childOptions = array(
            'delivery_bn'=>app::get('base')->_('发货单号'),
        );
        return $Options = array_merge($parentOptions,$childOptions);
	}

    public function _filter($filter,$tableAlias=null,$baseWhere=null)
    {   
        #发货单
        if(isset($filter['delivery_bn'])){
            $delivery_bn = $filter['delivery_bn'];
            $sql = "select expressadjust_id from sdb_wms_expressadjust_line  where  delivery_bn= '{$delivery_bn}'";
            
            $_rows = $this->db->select($sql);
            if(!empty($_rows)){
                foreach($_rows as $_orders){
                    $expressadjust_id[] = $_orders['expressadjust_id'];
                }
                $where .= ' AND id IN ('.implode(',', $expressadjust_id).')';
                unset($filter['delivery_bn']);
            }

        }

        return parent::_filter($filter,$tableAlias,$baseWhere).$where;
    }

   
}
